package cn.virens.web.components.websocket;

import java.security.Principal;
import java.util.Map;

import org.springframework.http.server.ServerHttpRequest;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;

import cn.virens.database.mysql.model.sys.SysUser;
import cn.virens.web.components.shiro.comm.SessionUtil;

public class WebSocketHandshakeHandler extends DefaultHandshakeHandler {
	@Override
	protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler, Map<String, Object> attributes) {
		return new SimplePrincipal((SysUser) attributes.get(SessionUtil.LOGIN_USER_INFO));
	}
}
